<template>
	<div>
		<span>分类</span>
		<el-select
			class="el-select"
			placeholder="请选择"
			size="mini"
			v-model="val"
			@change="val => $emit('change', val)"
		>
			<el-option label="全部" value></el-option>
			<el-option
				:label="item.label"
				:value="item.value"
				v-for="(item, i) in options"
				:key="i"
			></el-option>
		</el-select>
	</div>
</template>
<script>
import { cidType } from '@/dict/index';
export default {
	data() {
		return {
			options: [],
			val: ''
		};
	},
	props: {
		isLargeCoupon: {
			type: Boolean,
			default: false
		}
	},
	mounted() {
		if (this.isLargeCoupon) {
			this.$service.goodsMenagement.goods
				.bigCouponClassify()
				.then(res => {
					this.options = res.map(e => {
						return {
							label: e.name,
							value: e.id
						};
					});
				})
				.catch(err => console.error(err));
		} else {
			this.options = cidType;
		}
	}
};
</script>
<style lang="scss" scoped>
span {
	color: $text-grey;
	margin-right: 10px;
}
.el-select {
	width: 90px;
}
</style>
